package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.SystemLog;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemLogService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("systemLog")
public class SystemLogController {
    @Autowired
    private ISystemLogService systemLogService;

    @RequestMapping("")
    public String index(){
        return "systemLog/list";
    }

    @RequiresPermissions(value= {"systemLog:view","菜单列表"})
    @RequestMapping("list")
    @ResponseBody
    public PageResult list(QueryObject qo){
        return systemLogService.query(qo);
    }

    @RequestMapping("queryAllSystemLog")
    @ResponseBody
    //查询全部菜单
    public List<SystemLog> queryAllSystemLog(){

        //从session获取登录成功时候缓存的菜单集合
        return systemLogService.list();
    }



    @RequiresPermissions(value= {"systemLog:save","菜单保存"})
    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(SystemLog entity){
        JsonResult result = new JsonResult();
        try {
            systemLogService.save(entity);
        }catch (Exception e){
            e.printStackTrace();
            result.markMsg("保存操作失败");
        }
        return result;
    }


}
